package tcu.yuyp;

//创建Reversion类
public class Reversion {

    public String reverse(String s){
        if (s == null || s.isEmpty()){
            throw new IllegalArgumentException("传入的字符串不能为空");
        }
        if(!s.matches("[0-9|a-z|A-Z]+")){
            throw new IllegalArgumentException("必须为数字或者字母");
        }
        int length = s.length();
        if (length == 1 ){
            return s;
        }
        String lastChar = s.substring(length - 1);
        return lastChar + reverse(s.substring(0, length - 1));//递归调用
    }
}
